// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import Vant from 'vant'
import moment from 'moment'
import 'vant/lib/index.css';

import {
  Toast
} from 'vant'
import {
  Form
} from 'vant';
import {
  List
} from 'vant';
import {
  AddressEdit
} from 'vant';
import {
  Area
} from 'vant';
import axios from 'axios'
import VueLazyload from 'vue-lazyload'

Vue.use(VueLazyload, {

});
Vue.use(Area);
Vue.use(AddressEdit);
Vue.use(Form);

Vue.use(Vant);
Vue.use(List);
Vue.use(Toast);
Vue.prototype.$moment = moment

import {
  Dialog
} from 'vant';

// 全局注册
Vue.use(Dialog);
Vue.prototype.$axios = axios;
Vue.config.productionTip = false
// 请求拦截
axios.interceptors.request.use(config => {
  if ("prod-api/common/login" != config.url) {
    if (localStorage.getItem("token")) {
      config.headers['Authorization'] = 'Bearer ' + localStorage.getItem("token")
      console.log(localStorage.getItem("token"))
      // 让每个请求携带自定义token 请根据实际情况自行修
    }
  }
  return config;
}, err => {
  // todo 待完善接口拦截
  return Promise.reject(err);
});
/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  components: {
    App
  },
  template: '<App/>'
})
